package com.michael.study.component.activity

import android.os.Bundle
import android.util.Log
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import com.michael.study.component.R
import com.michael.study.component.activity.affinity.FirstAffinity1Activity
import com.michael.study.library.utils.Actions
import kotlinx.android.synthetic.main.activity_my.*

class MyActivity : AppCompatActivity(), View.OnClickListener {

    val TAG = "lgq " + javaClass.simpleName


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_my)
        btn_task_affinity.setOnClickListener(this)
        Log.d(TAG, "onCreate: ")
        savedInstanceState?.let {
            Log.d(TAG, "onCreate: " + it.getString("name"))
        }
    }

    override fun onRestart() {
        super.onRestart()
        Log.d(TAG, "onRestart: ")
    }

    override fun onStart() {
        super.onStart()
        Log.d(TAG, "onStart: ")
    }

    override fun onRestoreInstanceState(savedInstanceState: Bundle) {
        super.onRestoreInstanceState(savedInstanceState)
        Log.d(TAG, "onRestoreInstanceState: ")
    }

    override fun onSaveInstanceState(outState: Bundle) {
        super.onSaveInstanceState(outState)
        Log.d(TAG, "onSaveInstanceState: ")
        outState.putString("name","lee")
    }

    override fun onResume() {
        super.onResume()
        Log.d(TAG, "onResume: ")
    }

    override fun onPause() {
        super.onPause()
        Log.d(TAG, "onPause: ")
    }

    override fun onStop() {
        super.onStop()
        Log.d(TAG, "onStop: ")
    }

    override fun onDestroy() {
        super.onDestroy()
        Log.d(TAG, "onDestroy: ")
    }

    override fun onClick(v: View?) {
        when (v?.id) {
            R.id.btn_task_affinity -> {
                Actions.startActivity(this,FirstAffinity1Activity::class.java)
            }

            R.id.btn_bind -> {
            }
        }

    }
}